<?php

  /*

      TravianWAP
      Copyright (c) 2007-08 by Ananas - All rights reserved
      http://n00bz.biz/travianwap/
      Contact: uroskn@gmail.com

      --------------------------------------------------------------------------

      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU  General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU  General Public License
      along with this program. If not, see http://www.gnu.org/licenses/.

  */

  define("MODULE_OK", 1);
  
  echo "<b>Multi village overview</b><br/><br/>";
  
  $vill = travian_return_villages($txt, True);

  if (count($vill) > 2)
  {
    for ($i = 1; $i < count($vill); $i++)
    {
      $text = http_get("http://{$_SESSION["serv"]}/dorf1.php?newdid={$vill[$i]["id"]}");
      $text = $text["body"];
      $res = travian_extract_resource_count($text, True);
      $prod = travian_extract_resource_page_info($text, True);
      $constr[$i] = $prod["construction"];
      echo "<b>";
      print_link('main.php?mod=direct_call&amp;newdid='.$vill[$i]["id"].'&amp;file=dorf1&amp;return=main'.ps(), $vill[$i]["name"]);
      echo "</b><br/>{$res[0][0]} {$res[1][0]} {$res[2][0]}/{$res[0][1]}<br/>".
           "{$res[3][0]}/ {$res[3][1]}<br/>".
           "{$prod["production"][0]}|{$prod["production"][1]}|{$prod["production"][2]}|{$prod["production"][3]}<br/>";
      if (!empty($prod["construction"][0]["title"]))
      {
        for ($x = 0; $x < 3; $x++)
        {
          if (!empty($prod["construction"][$x]["title"]))
          {
              echo "C:".$prod["construction"][$x]["title"]."<br/>".
              " ".pdate($prod["construction"][$x]["end"])." - ".pdate($prod["construction"][$x]["endat"], False)."<br/>";
          }
        }
      }
      echo "<br/>";
    }
  }
  else echo "You have only one village.<br/><br/>";
  

